﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PiaoanWeb.AppLogic.BusinessLogicLayer;
using PiaoanWeb.AppLogic.DataAccessLayer;
using PiaoanWeb.Helpers;
namespace PiaoanWeb
{
    public partial class NewsList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                NewsBLL newsBLL = new NewsBLL();
                NewsGridView.DataSource = newsBLL.GetAllNews();
                NewsGridView.DataBind();
            }
        }

        protected void NewsGridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Label indexLbl = e.Row.FindControl("indexLbl") as Label;
                indexLbl.Text = (e.Row.RowIndex + 1).ToString();
            }
        }

        protected void NewsGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            NewsGridView.PageIndex = e.NewPageIndex;
            NewsBLL newsBLL = new NewsBLL();
            NewsGridView.DataSource = newsBLL.GetAllNews();
            NewsGridView.DataBind();
        }
    }
}